/*-----------------------------------------------------------------------------------

 	Custom JS - All front-end jQuery
 
-----------------------------------------------------------------------------------*/
 
 
/*-----------------------------------------------------------------------------------*/
/*	Let's get ready!
/*-----------------------------------------------------------------------------------*/

jQuery(document).ready(function() {



/*-----------------------------------------------------------------------------------*/
/*	Image Overlays
/*-----------------------------------------------------------------------------------*/
	
	function tz_postThumbOverlay() {
	
		var postThumb = jQuery('.grid .post-thumb a');
		
		postThumb.hover( function() {
		
			jQuery(this).find('.post-thumb-overlay').stop().css({
				opacity: 0,
				display: 'block'
			}).animate({
				opacity: 1
			}, 150);
			
		}, function() {
			jQuery(this).find('.post-thumb-overlay').stop().fadeOut(150);
		});
		
	}
	
	tz_postThumbOverlay();
	
	
/*-----------------------------------------------------------------------------------*/
/*	Post Thumb Hover Effects
/*-----------------------------------------------------------------------------------*/
	
	var postThumb = jQuery('#primary .post-thumb a');
		
	postThumb.hover( function() {
		jQuery(this).animate({ opacity: 0.8 }, 200);
	}, function() {
		jQuery(this).animate({ opacity: 1 }, 200);
	});
	
	
/*-----------------------------------------------------------------------------------*/
/*	Sticky Footer
/*-----------------------------------------------------------------------------------*/
	
	function stickyFooter() {
		
		var windowHeight = jQuery(window).height();
		var footerHeight = jQuery('#footer').outerHeight() + 100;
		
		jQuery('#content').css('min-height', windowHeight - footerHeight);
		
	}
	
	stickyFooter();
	
	jQuery(window).resize( function () {
		stickyFooter();
	});
	
/*-----------------------------------------------------------------------------------*/
/*	Back to Top
/*-----------------------------------------------------------------------------------*/


	function tz_backToTop() {
		
		var topLink = jQuery('#back-to-top');
		
		if(jQuery(window).scrollTop() > 0) {
			topLink.fadeIn(200);
		} else {
			topLink.fadeOut(200);
		}
	}
	
	jQuery(window).scroll( function() {
		tz_backToTop();
	});
	
	jQuery('#back-to-top').click( function() {
		jQuery('html, body').stop().animate({scrollTop:0}, 500);
		return false;
	});


	jQuery('#back-to-top').hover( function() {
		jQuery(this).stop().animate({
			paddingRight: 20
		}, 200);
	}, function () {
		jQuery(this).stop().animate({
			paddingRight: 10
		}, 200);
	});
	
/*-----------------------------------------------------------------------------------*/
/*	Overlay
/*-----------------------------------------------------------------------------------*/
		
	var overlayTrigger = jQuery('#overlay-trigger a');
	
	var overlayState = 'close';
	
	overlayTrigger.toggle( function() {
	
		overlayState = 'open';
		
		jQuery('#overlay').css({
			top: -jQuery('#overlay').outerHeight()
		});
		
		overlayTrigger.addClass('active');
		
		jQuery('#overlay').animate({
			top: 0
		}, 700, 'easeInOutQuart');
		
		jQuery('#overlay-trigger').animate({
			top: jQuery('#overlay').outerHeight() + 10
		}, 700, 'easeInOutQuart');
		
	}, function () {
		
		overlayState = 'close';
		
		overlayTrigger.removeClass('active');
		
		jQuery('#overlay').animate({
			top: -jQuery('#overlay').outerHeight()
		}, 700, 'easeInOutQuart');
		
		jQuery('#overlay-trigger').animate({
			top: 10
		}, 700, 'easeInOutQuart');
		
	});
	
/*-----------------------------------------------------------------------------------*/
/*	All done!
/*-----------------------------------------------------------------------------------*/

});